import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        token: '',
        adminInfo: JSON.parse(sessionStorage.getItem("adminInfo"))
    },
    mutations: {
        SET_TOKEN: (state, token) => {
        state.token = token
    localStorage.setItem("token", token)
},
SET_USERINFO: (state, adminInfo) => {
    state.adminInfo = adminInfo
    sessionStorage.setItem("adminInfo", JSON.stringify(adminInfo))
},
REMOVE_INFO: (state) => {
    localStorage.setItem("token", '')
    sessionStorage.setItem("adminInfo", JSON.stringify(''))
    state.adminInfo = {}
}
},
getters: {
    getAdmin: state => {
        return state.adminInfo
    }
},
actions: {},
modules: {}
})
